(function($, window) {
	'use strict';

	window.bar = $.extend({
		size: 30,
		code: undefined
		// code: {
		// 	src:'/images/questionMark.png',
		// 	width:50,
		// 	height:50
		// }
	}, window.bar);

	var $bar = $("<div></div>"),
		_size = window.bar.size,
		_barCode = window.bar.barCode,
		$cert = $("<div></div>"),
		$totop = $("<div><img style='width:100%;height:100%' src='' /></div>"),

		$qq = $("<div><img style='width:100%;height:100%' src='' /></div>"),

		$code = $("<div><img style='width:100%;height:100%' src='' /></div>"),
		$barCode;

	if(window.bar.code){
		$barCode = $("<img src='"+window.bar.code.src+"' />");
		$barCode.css({
			position:'absolute',
			width:window.bar.code.width,
			height:window.bar.code.height,
			left:-window.bar.code.width-3,
			bottom:0,
			display:'none'
		})
		.appendTo($bar);
	}

	$cert
		.css({
			border: _size / 6 + 'px solid transparent',
			borderBottomColor: '#ededed',
			width: 0,
			height: 0,
			position: 'absolute',
			top: -_size / 6 * 2,
			left: _size / 2 - _size / 6
		})
		.appendTo($bar);

	$totop
		.css({
			width: _size,
			height: _size,
			marginBottom: 3
		})
		.on('click', function() {
			$(window).scrollTop(0);
		})
		.appendTo($bar);
	$qq.css({
			width: _size,
			height: _size,
			marginBottom: 3
		})
		.on('click', function() {
			location.hash = 'qq';
			$(window).scrollTop($("a[name=qq]").offset().top);
		})
		.appendTo($bar);
	if (window.bar.code) {
		$code.css({
				width: _size,
				height: _size
			})
			.on('mouseover', function() {
				$barCode.show();
			}).on('mouseout',function(){
				$barCode.hide();
			})
			.appendTo($bar);
	}
	$bar.css({
		cursor: 'pointer',
		position: 'fixed',
		top: '60%',
		right: 0
	}).appendTo($("body"));


})(jQuery, window);